package xiu_xiu.base;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.xiu_xiu.R;

import xiu_xiu.view_A_main.GoldAnnouncementActivity;
import xiu_xiu.view_A_main.MyActivity;
import xiu_xiu.view_A_main.RescueActivity;
import xiu_xiu.view_A_main.SOSActivity;


/**
 * Created by 阳 on 2016/4/1.
 */
public class MainActivity extends BaseActivity {
    public LinearLayout ll1;
    public LinearLayout ll2;
    public LinearLayout ll3;
    public LinearLayout ll4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    }

    /**
     * 获取控件,添加监听,更改底控件的颜色
     */
    public void bottomNavigation(int id) {

        ll1 = (LinearLayout) findViewById(R.id.bottom_bar_ll1);
        ll2 = (LinearLayout) findViewById(R.id.bottom_bar_ll2);
        ll3 = (LinearLayout) findViewById(R.id.bottom_bar_ll3);
        ll4 = (LinearLayout) findViewById(R.id.bottom_bar_ll4);
        addColor(id);
        ll1.setOnClickListener(onClickListener);
        ll2.setOnClickListener(onClickListener);
        ll3.setOnClickListener(onClickListener);
        ll4.setOnClickListener(onClickListener);
    }

    private View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.bottom_bar_ll1:
                    SOSActivity.startUI(MainActivity.this);
                    break;
                case R.id.bottom_bar_ll2:
                    RescueActivity.startUI(MainActivity.this);
                    break;
                case R.id.bottom_bar_ll3:
                   GoldAnnouncementActivity.startUI(MainActivity.this);
                    break;
                case R.id.bottom_bar_ll4:
                    MyActivity.startUI(MainActivity.this);
                    break;
            }
        }
    };

    private void addColor(int id) {
        ((ImageView) ((LinearLayout) findViewById(id)).getChildAt(0)).setImageResource(R.mipmap.help);
        ((TextView) ((LinearLayout) findViewById(id)).getChildAt(1)).setTextColor(0xff0000ff);
    }

    @Override
    public void onBackPressed() {
        Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT);
    }
}
